/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:12
 *
 */
import {RequestAction, RequestMethod} from "../configuration/RequestConfiguration"
import {AppRequestPath,ContextPath} from "../configuration/AppConfig"
import {API_LOGIN,API_PROCEDURE2} from "../constant/API"
import global from "../configuration/global";

/**
 * 登录
 * @param action
 * @param username 用户名
 * @param password 密码
 * @param hotelId 酒店编号
 * @returns {*}
 */
export const requestLogin = (action, username, password, hotelId) => {
  return RequestAction(
    AppRequestPath() + API_LOGIN,
    RequestMethod.Post,
    {
      'userid': username,
      'upass': password,
      'hotelId': hotelId
    },
    action
  )
};


/**
 * 获取缓存数据
 * @param action
 * @param hotelId
 * @returns json
 */
export const requestSetCache = (action, hotelId) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': hotelId,
            'fu': "QmsRetrieveCacheData",
            'jn': '{}',
            'jnJson2': '{}',
        },
        action
    )
};

/**
 * 下班
 * @param action
 * @param str
 * @returns json
 */
export const requestOffWork = (action, str) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': global.hotelId,
            'fu': "QmsHoLogOut",
            'jn': str,
            'jnJson2': '{}',
        },
        action
    )
};


/**
 * 下班
 * @param action
 * @returns json
 */
export const requestRedPoint = (action) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': global.hotelId,
            'fu': "WHSKMenuMain",
            'jn': '{}',
            'jnJson2': '{}',
        },
        action
    )
};


/**
 * 房态盘timer
 * @param action
 * @returns json
 */
// let paramSocket = {hotelId:global.hotelId,websocketName:"websocketroomsview",fu:"RetrieveRoomsViewAs",jn:JSON.stringify({
//         "wherestatus":{"All":"1"},
//         "arg":{"arg":"房务"},
//         "where":{"building":"","rmtype":"","floor":"","allSearch":"","source":"","market":"","features":"","grno":""}
//     }),json:JSON.stringify({"output":{"json":"null"}}),type:"proc"}
export const requestCreateFtpTimer = (action) => {
    return RequestAction(
        ContextPath() + '/frontofficeTimer/creTimer',
        RequestMethod.Post,
        {
            'hotelId':global.hotelId,
            'websocketName':"websocketroomsview",
            'fu':"RetrieveRoomsViewAs",
            'jn':JSON.stringify({
                "wherestatus":{"All":"1"},
                "arg":{"arg":"房务"},
                "where":{"building":"","rmtype":"","floor":"","allSearch":"","source":"","market":"","features":"","grno":""}
            }),
            'json':JSON.stringify({"output":{"json":"null"}}),
            'type':"proc"
        },
        action
    )
};

export const requestSetAlinarg = (action) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': global.hotelId,
            'fu': "ListRetrieveAlinarg",
            'jn': '{}',
            'jnJson2': '{}',
            "jnJson3" : "list",
        },
        action
    )
};

export const requestSetButtonRight = (action) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': global.hotelId,
            'fu': "HoLoginStoreList",
            'jn': '{}',
            'jnJson2': '{}',
        },
        action
    )
};





